'''
Author: didiplus
Date: 2024-10-15 16:53:53
LastEditTime: 2024-10-15 17:10:55
LastEditors: didiplus
Description: 爱因斯坦的数学题
FilePath: \pythonscript\python\趣学Python算法100例\17、爱因斯坦的数学题\demo.py
'''


def computing_ladder(n):
    # 输入验证
    if not isinstance(n, int) or n < 1:
        raise ValueError("n must be a positive integer")

    print(f"在1-{n}之间的阶梯数为：")
    count = 0
    for i in range(7, n+1):
        # 阶梯数所满足的条件
        if (i % 7 == 0) and (i % 6 == 5) and (i % 5 == 4) and (i % 3 == 2):
            count += 1                              # count记录1～n之间满足条件的阶梯个数
            print(f"{i}")
    print(f"在1-{n}之间，有{count}个数可以满足爱因斯坦对阶梯的要求。")

if __name__=="__main__":
    while True:
        n = int(input("请输入n值："))
        computing_ladder(n)

